enum MemberRole {
  admin,
  member,
  guest,
}

class Member {
  final String id;
  String name;
  String email;
  String? password;
  MemberRole role;
  final DateTime createdAt;
  bool isActive;

  Member({
    required this.id,
    required this.name,
    required this.email,
    this.password,
    this.role = MemberRole.member,
    this.isActive = true,
  }) : createdAt = DateTime.now();

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'name': name,
      'email': email,
      'password': password,
      'role': role.toString(),
      'created_at': createdAt.toIso8601String(),
      'is_active': isActive ? 1 : 0,
    };
  }

  factory Member.fromMap(Map<String, dynamic> map) {
    return Member(
      id: map['id'],
      name: map['name'],
      email: map['email'],
      password: map['password'],
      role: MemberRole.values.firstWhere(
        (e) => e.toString() == map['role'],
        orElse: () => MemberRole.member,
      ),
      isActive: map['is_active'] == 1,
    );
  }
} 